package com.general.adminserver.resource;

import com.general.adminserver.service.TestService;
import com.general.common.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

/**
 * @author Songjiuhua
 * @date 2018-01-30
 */
@Path("")
@Component
public class TestResource {

    @Autowired
    private TestService testService;
    @Value("${foo}")
    String foo;
    @Autowired
    private RedisUtils redisUtils;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("hello")
    public Response sayHello( @QueryParam("name") String name){
        System.out.println(foo);
        redisUtils.set("test", "123");
        System.out.println(redisUtils.get("test"));
        return Response.ok(testService.sayHello(name)).build();
    }

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("getUserInfo")
    public Response getUserInfo(){
        return Response.ok(testService.queryUserInfo()).build();
    }

}
